package edu.colorado.core;

import java.io.Serializable;

public class HighScore implements Serializable, Comparable<HighScore> {
    private static final long serialVersionUID = -6887718234194608704L;

    private String name;
    
    private int score;
    
    public HighScore(String name, int score) {
        this.name = name;
        this.score = score;
    }
    
    public int getScore() {
        return score;
    }
    
    public String getName() {
        return name;
    }
    
    @Override
    public String toString() {
        return name + ", " + score;
    }
    
    @Override
    public boolean equals(Object other) {
        if (other instanceof HighScore) {
            return score == ((HighScore) other).score &&
                    name.equals(((HighScore) other).name);
        } else {
            return false;
        }
    }
    
    @Override
    public int compareTo(HighScore other) {
        if (score == other.score) {
            return name.compareTo(other.name);
        } else {
            return score - other.score;
        }
    }
}
